#include "core/types.hpp"

namespace FastMD 
{
	const size_t V3D::SIZE = sizeof(V3D);
	
	Real Normal() throw()
	{
		static const Real two_pi   = REAL_TWO_PI;
		static bool       generate = true;
		static Real       g2       = 0;
		if( generate)
		{
			const Real x1     = Rand();
			const Real x2     = Rand();
			const Real angle  = two_pi * x2;
			const Real half_r = - __log( x1 );
			const Real radius = __sqrt( half_r + half_r );
			const Real g1     = radius * __cos( angle );
			g2                = radius * __sin( angle );
			generate = false;
			return g1;
		}
		else 
		{
			generate = true;
			return g2;
		}
	}
	
	
}
